<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/21
 * Time: 15:12
 */

namespace app\api\model;


class Goods extends BaseModel
{
//    protected $hidden = ['simple_name','category','cost_price','market_price','is_on_sale','is_home_page','sales_num','cover_img_origin','cover_sm_img','create_time','update_time','delete_time'];

    //商品,商品相册的关联模型
    public function goodsImage(){
        return $this->hasMany('GoodsImage','goods_id','id');
    }


    public function getCoverImgAttr($value,$data)
    {
        $finalUrl = $value;
        if($data['cover_img_origin'] == 0){
            $finalUrl = config('setting.img_prefix').$value;
        }
        return $finalUrl;
    }
}